//package com.zyc.config;
//
//
//
//import com.zyc.service.userServiceImpl;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
//import org.springframework.security.crypto.password.NoOpPasswordEncoder;
//import org.springframework.security.crypto.password.PasswordEncoder;
//
//
//@Configuration
//@EnableWebSecurity
//
//public class securityConfig extends WebSecurityConfigurerAdapter{
//    @Autowired
//    userServiceImpl userService;
//
//    @Override
//    protected void configure(HttpSecurity http) throws Exception {
//
//        // 禁用csrf
//        http.csrf(AbstractHttpConfigurer::disable);
//
//        http.authorizeRequests().antMatchers("/").permitAll()
//                .antMatchers("/level1/**").hasRole("vip1")
//                .antMatchers("/level2/**").hasRole("vip2")
//                .antMatchers("/level3/**").hasRole("vip3");
//
//        http.formLogin().loginPage("/toLogin");
////        http.csrf().disable();//关闭csrf功能:跨站请求伪造,默认只能通过post方式提交logout请求
////
////        // 开启自动配置的登录功能
////        // loginPage("/toLogin")定制登录首页 .usernameParameter("user")定制用户参数.passwordParameter()定制密码参数
////        http.formLogin().loginPage("/toLogin");
////        //开启自动配置的注销的功能logout 注销请求
//
//
//
//
//    }
//    @Override
//    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
//            auth.userDetailsService(userService)
//                    .passwordEncoder(passwordEncoder());}
//
//
//
//    @Bean
//    public PasswordEncoder passwordEncoder()
//    {
//        return NoOpPasswordEncoder.getInstance();
//    }
//}
//
